Skip to content

feat: expose package manager name in componentAnalysis result#518

Merged
a-oren merged 3 commits into
guacsec:mainfrom
a-oren:TC-4336
May 18, 2026
Merged

feat: expose package manager name in componentAnalysis result#518
a-oren merged 3 commits into
guacsec:mainfrom
a-oren:TC-4336

Conversation

@a-oren

@a-oren a-oren commented May 13, 2026

Copy link
Copy Markdown
Contributor

Summary

  • Attach the matched provider's _cmdName() (e.g. pip, uv, poetry, npm, pnpm, yarn) as packageManager on the component analysis result
  • Add _cmdName() to the python_pip plain object provider for consistency with class-based providers
  • Enables IDE consumers to display provider-specific instructions (e.g. trusted registry configuration) without re-implementing provider detection

Test plan

  • All existing tests pass (418 passing, 19 pre-existing failures from missing system tools)
  • Verified packageManager is set correctly for all Python providers: requirements.txtpip, pyproject.toml + uv.lockuv, pyproject.toml + poetry.lockpoetry, pyproject.toml (no lock) → pip
  • Verified JavaScript providers also get packageManager set (npm, pnpm, yarn)
  • Verified non-class providers (Go, Cargo) are unaffected (no _cmdName, no packageManager set)

Jira: TC-4336

🤖 Generated with Claude Code

Summary by Sourcery

Expose the matched provider’s package manager name on component analysis results and align the Python pip provider with other providers.

New Features:

  • Attach a packageManager field to component analysis responses when the matched provider exposes a command name.
  • Define a command name for the python_pip provider so its package manager can be surfaced to consumers.

Attach the matched provider's command name (e.g. pip, uv, poetry) as
`packageManager` on the component analysis result so IDE consumers can
display provider-specific instructions without re-implementing detection.

Jira: TC-4336

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@sourcery-ai

sourcery-ai Bot commented May 13, 2026

Copy link
Copy Markdown
Reviewer's guide (collapsed on small PRs)

Reviewer's Guide

Exposes the underlying provider command name as packageManager in componentAnalysis results and adds a cmdName implementation for the plain python_pip provider so IDEs can show package-manager-specific guidance.

Sequence diagram for updated componentAnalysis packageManager enrichment

sequenceDiagram
  participant Caller
  participant componentAnalysis
  participant match
  participant provider
  participant analysis

  Caller->>componentAnalysis: componentAnalysis(manifest, opts)
  componentAnalysis->>componentAnalysis: fs.accessSync(manifest)
  componentAnalysis->>componentAnalysis: path.basename(manifest)
  componentAnalysis->>match: match(manifest, availableProviders, opts)
  match-->>componentAnalysis: provider
  componentAnalysis->>analysis: requestComponent(provider, manifest, theUrl, opts)
  analysis-->>componentAnalysis: result
  alt provider has _cmdName
    componentAnalysis->>provider: _cmdName()
    provider-->>componentAnalysis: commandName
    componentAnalysis->>componentAnalysis: result.packageManager = commandName
  end
  componentAnalysis-->>Caller: result
Loading

File-Level Changes

Change Details Files
Attach provider command name as packageManager on componentAnalysis results when available.
  • Capture the componentAnalysis requestComponent result in a local variable before returning.
  • Check if the resolved provider exposes a callable _cmdName function.
  • Populate result.packageManager with provider._cmdName() when present and return the enriched result.
src/index.js
Add a _cmdName implementation to the python_pip provider to align with other class-based providers.
  • Extend the python_pip default export object to include a _cmdName method.
  • Ensure _cmdName returns the literal string 'pip' so componentAnalysis can consistently tag Python requirement-based projects with pip as the packageManager.
src/providers/python_pip.js

Tips and commands

Interacting with Sourcery

  • Trigger a new review: Comment @sourcery-ai review on the pull request.
  • Continue discussions: Reply directly to Sourcery's review comments.
  • Generate a GitHub issue from a review comment: Ask Sourcery to create an
    issue from a review comment by replying to it. You can also reply to a
    review comment with @sourcery-ai issue to create an issue from it.
  • Generate a pull request title: Write @sourcery-ai anywhere in the pull
    request title to generate a title at any time. You can also comment
    @sourcery-ai title on the pull request to (re-)generate the title at any time.
  • Generate a pull request summary: Write @sourcery-ai summary anywhere in
    the pull request body to generate a PR summary at any time exactly where you
    want it. You can also comment @sourcery-ai summary on the pull request to
    (re-)generate the summary at any time.
  • Generate reviewer's guide: Comment @sourcery-ai guide on the pull
    request to (re-)generate the reviewer's guide at any time.
  • Resolve all Sourcery comments: Comment @sourcery-ai resolve on the
    pull request to resolve all Sourcery comments. Useful if you've already
    addressed all the comments and don't want to see them anymore.
  • Dismiss all Sourcery reviews: Comment @sourcery-ai dismiss on the pull
    request to dismiss all existing Sourcery reviews. Especially useful if you
    want to start fresh with a new review - don't forget to comment
    @sourcery-ai review to trigger a new review!

Customizing Your Experience

Access your dashboard to:

  • Enable or disable review features such as the Sourcery-generated pull request
    summary, the reviewer's guide, and others.
  • Change the review language.
  • Add, remove or edit custom review instructions.
  • Adjust other review settings.

Getting Help

@sourcery-ai sourcery-ai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@ruromero ruromero left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

let's try to make it more generic and maintainable.

Comment thread src/providers/python_pip.js Outdated
Comment thread src/index.js Outdated
a-oren and others added 2 commits May 18, 2026 09:53
Keep _cmdName as the internal/protected method for binary resolution
and add packageManagerName() as the proper public method on every
provider. This ensures result.packageManager is always set for all
providers, not just when _cmdName happens to exist.

Jira: TC-4336

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@a-oren
a-oren requested a review from ruromero May 18, 2026 08:15
@a-oren
a-oren merged commit ff694a0 into guacsec:main May 18, 2026
5 checks passed
@a-oren
a-oren deleted the TC-4336 branch June 4, 2026 06:43
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants